<?php
if (! defined ( FLAG )){ trigger_error('Access error!', E_USER_ERROR); die; }

global $STR;
$STR->setVar(array('DATA','title'),'Driver-cmf | Крестики-нолики');
$STR->setVar(array('DATA','main_text'),'');

	$BD = $STR->getVar(array('BD'));

if(isset($_SESSION['online'])){

	if (isset($_POST['addGame'])) {
	$res = $BD->Query('INSERT INTO  `krestikii-noliki`.`games` (
					`id` ,
					`owner` ,
					`user`,
					`openly` ,
					`game_map` ,
					`time`
					)VALUES (NULL ,  \''.$_SESSION['id_gamers'].'\',\'-1\',  \'1\',  \'{}\', NOW( ));');
	}

	$Query=$BD->Query('SELECT distinct games.id,games.owner,games.time, gamers.login FROM `krestikii-noliki`.`games`,`krestikii-noliki`.`gamers` WHERE games.openly = \'1\' and games.owner = gamers.id');
		
	while($res = $Query->Fetch()) {
		$list_games[]=$res;
	}	

}

if(isset($list_games)){
	$STR->setVar(array('DATA','list_games'),$list_games);
}

//var_dump($_POST);
//var_dump($_SESSION);


?>
